< previous page page_630 next page >

Page 630
The complete lighting model including directly transmitted light becomes:
I = Ia * ka + 
    I
i * (kd * (L · N) + ks * (R  V)n) * 
        (r
min + kdist) / (r + kdist) + 
    I
r * kr + 
    I
i * kt * (V  T)Nt
Note that either the specular term or the direct transmitted term, but not both, can be nonzero. If the light source and viewpoint are on the same side of the surface, there is specular reflection. Because the light source and viewpoint are on the same side of the surface, any light that enters the object will not reach the viewpoint directly, so there can be no direct transmitted light.
Similarly if the light source and viewpoint lie on opposite sides of the surface, any light that is specularly reflected will not enter the object, so it cannot reach the viewpoint directly.
Indirectly Transmitted Light
The global component of transmitted light is indirectly transmitted. This is light that passes through a transparent object but does not originate directly at the light source. To compute the contribution due to this light, you need to follow a ray in the direction of refraction. When that ray strikes an object, use the color of that object to determine the contribution due to the ray. Adding a term for indirect transmission the lighting model becomes:
I = Ia * ka + 

    I
i * (kd * (L · N) + ks * (R · V)n) *
        (r
min + kdist) / (r + kdist) +
    I
r * kr +
    I
i * kt * (V · T)Nt +
    I
t * kt
The constant kt represents the transparency of the object. You can use the same value for both the direct and indirect transmitted components.
Transparent Surfaces in Visual Basic
To implement transparent objects in Visual Basic, you need to be able to determine the indexes of refraction before and after a light ray crosses a surface boundary. There are many ways you could keep track of the kinds of material through which a light ray passed. The approach taken here is one of the simpler options.
Each object has two indexes of refraction: N1 and N2. The value N1 is the index of refraction outside the object, and N2 is the index of refraction inside. Each object's HitColor subroutine uses the normal vector to determine whether the light ray is entering or leaving the object. If the normal vector points in more or less the same direction as the ray, the ray is leaving the object. If the normal vector and the ray meet at an angle greater than 90 degrees, the ray is entering the object.

 
< previous page page_630 next page >